package com.ctrl.riveradministrator.mvp.view.activity.river_info;

import android.content.Context;
import android.graphics.Color;
import android.os.Build;
import android.os.Message;
import android.support.annotation.RequiresApi;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.ctrl.riveradministrator.R;
import com.ctrl.riveradministrator.base.BaseActivity;
import com.ctrl.riveradministrator.base.BasePresenter;
import com.ctrl.riveradministrator.mvp.model.RiverInfo;

public class RiverDetailActivity extends BaseActivity {

    private Toolbar toolbar;
    private TextView titleTv;
    private ImageView leftMenu;

    private RiverInfo riverInfo;
    private TextView name,ly,sx,hllb,hldj,hllx,hlab,hlcd,hydm,hkdm;

    @Override
    protected void initParams(Bundle parms) {
        riverInfo = (RiverInfo) getIntent().getSerializableExtra("river_info");
    }

    @Override
    protected int bindLayout() {
        return R.layout.activity_river_detail;
    }

    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    @Override
    protected void initView(View view) {
        toolbar = (Toolbar) $(R.id.toolbar);
        titleTv = (TextView) $(R.id.title_tv);
        leftMenu = (ImageView) $(R.id.left_iv);
        name = (TextView) $(R.id.name);
        ly = (TextView) $(R.id.ly);
        sx = (TextView) $(R.id.sx);
        hllb = (TextView) $(R.id.hllb);
        hldj = (TextView) $(R.id.hldj);
        hllx = (TextView) $(R.id.hllx);
        hlab = (TextView) $(R.id.hlab);
        hlcd = (TextView) $(R.id.hlcd);
        hydm = (TextView) $(R.id.hydm);
        hkdm = (TextView) $(R.id.hkdm);

        /*
         * 设置toolbar
         * */
        toolbar.setTitleTextColor(Color.WHITE);
        toolbar.setTitle("");
        titleTv.setText(riverInfo.getRiverName()+"详细信息");
        leftMenu.setBackground(getDrawable(R.drawable.ic_chevron_left_24dp));
    }

    @Override
    protected void doBusiness(Context mContext) {
        name.setText(riverInfo.getRiverName());
        ly.setText(riverInfo.getBasinName());
        sx.setText(riverInfo.getWaterSystemName());
        hllb.setText(riverInfo.getCategoryName());
        hldj.setText(riverInfo.getGradeName());
        hllx.setText(riverInfo.getTypeName());
        hlab.setText(riverInfo.getShoreSeparationName());
        hlcd.setText(riverInfo.getRiverLength());
        hydm.setText(riverInfo.getRiverAreaName());
        hkdm.setText(riverInfo.getEstuaryAreaName());
    }

    @Override
    protected void widgetClick(View view) {
        switch (view.getId()) {
            case R.id.left_iv:
                finish();
                break;
        }
    }

    @Override
    protected void setListener() {
        leftMenu.setOnClickListener(this);
    }

    @Override
    public void handleMessage(Message message, int what) {

    }

    @Override
    protected BasePresenter createPresenter() {
        return null;
    }
}
